package cuiyt.offer;

import java.util.ArrayList;
import java.util.Stack;

/**
 * @author cyt
 * @create 2020-05-19 16:15
 */
public class T4 {

    public static ArrayList<Integer> main(ListNode listNode) {

        ArrayList<Integer> list = new ArrayList<Integer>();

        if (listNode == null) {
            return list;
        }

        Stack<Integer> stack = new Stack<>();


        while (listNode != null) {
            stack.push(listNode.val);
            listNode = listNode.next;
        }


        while (!stack.isEmpty()) {
            list.add(stack.pop());
        }

        return list;
    }
}

class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}
